<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Filter</title>
</head>
<body>
<p id="cars"></p>
<p id="lovers"></p>
<script>
    let cars=[
        {"id":1,"name":'奥迪Q5', price: 899},
        {"id":2,"name":'沃尔沃XC60', price: '899'},
        {"id":3,"name":'林肯冒险家', price: 799},
        {"id":4,"name":'比亚迪汉', price: 699},
        {"id":5,"name":'哈佛H9', price: 399},
    ]

    function myLovers(car) {
        let r=car.price>=499;
        console.log(car.name, car.price,r);
        return r;
    }

    document.getElementById('cars').innerHTML=cars.filter(myLovers)

    document.getElementById('lovers').innerHTML=cars.filter(myLovers).map(function (x) {
           return x.name+" "+x.price;
    }).join('|')

var wdlm=['France','britain','China','Usa','russia']
console.log(wdlm.sort())
    console.log(wdlm.sort(function (x,y) {
          let a=x.toLowerCase();
          let b=y.toLowerCase();
          let r=0;
        if (a > b) {
            r=1;
        }else if (a== b) {
            r=0;
        }else {
            r=-1;
        }

        return r;
    }))


    var data=[10, 20, 1, 2,-1,66,9]
    console.log(data.sort());

    console.log(data.sort(function (x,y) {
        let a = Number(x);
        let b = Number(y);
        if (a > b) {
            return 1;
        }
        if (a < b) {
            return -1;
        }

        return 0;
    }))
</script>
</body>
</html>